package com.wenlin.myproduction.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


import com.wenlin.myproduction.R;
import com.wenlin.myproduction.bean.ScheduleTopBean;
import com.wenlin.myproduction.util.Checker;
import com.wenlin.myproduction.util.UI;

import me.drakeet.multitype.ItemViewBinder;

/**
 * @author 文琳_377979485@qq.com
 * @time 2021/10/13 0013 上午 9:23
 * @desc 排班管理的上侧列表条目——标题列表条目
 */
public class ScheduleTopBinder extends ItemViewBinder<ScheduleTopBean, ScheduleTopBinder.ScheduleTopHolder> {


    @NonNull
    @Override
    protected ScheduleTopHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new ScheduleTopHolder(inflater.inflate(R.layout.item_schedule_top, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull ScheduleTopHolder holder, @NonNull ScheduleTopBean item) {
        UI.setText(holder.tvWeek, item.getWeek());
        UI.setText(holder.tvDate, item.getDate());
        UI.setVisibleGone(holder.tvDesc, Checker.hasWord(item.getDesc()));
        UI.setText(holder.tvDesc, item.getDesc());
        //当日期和当前真实日期一样的时候，将显示星期几的文字变成橙色
        UI.setTextColor(holder.tvWeek, item.isOrange() ? R.color.myOrange : R.color.myWhite);
    }

    static class ScheduleTopHolder extends RecyclerView.ViewHolder {
        TextView tvWeek, tvDate, tvDesc;

        public ScheduleTopHolder(@NonNull View itemView) {
            super(itemView);
            tvWeek = itemView.findViewById(R.id.tv_week);
            tvDate = itemView.findViewById(R.id.tv_date);
            tvDesc = itemView.findViewById(R.id.tv_desc);
        }
    }
}
